package git.soulbgm.sync.web;

import git.soulbgm.sync.mapper.SqlMapper;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 数据库同步控制器
 *
 * @author SoulBGM
 * @date 2022/04/24 15:12
 */
@RequestMapping("/executeSql")
public class DBSyncController {

    private SqlMapper mapper;

    public DBSyncController(SqlMapper mapper) {
        this.mapper = mapper;
    }

    @PostMapping
    @ResponseBody
    public boolean executeSql(String sql) {
        if (sql == null) {
            return false;
        }
        return mapper.executeSql(sql) > 0;
    }

}
